import Vue from 'vue'
import App from './App'
Vue.config.productionTip = false

App.mpType = 'app'

import store from "./store"

Vue.prototype.$store = store

// 引入uView库
import uView from "uview-ui";
Vue.use(uView);


const prePage = ()=>{
	let pages = getCurrentPages();
	let prePage = pages[pages.length - 2];
	// #ifdef H5
	return prePage;
	// #endif
	return prePage.$vm;
}
// 注册全局组件
import MescrollBody from "@/components/mescroll-uni/mescroll-body.vue"
import MescrollUni from "@/components/mescroll-uni/mescroll-uni.vue"
Vue.component('mescroll-body', MescrollBody)
Vue.component('mescroll-uni', MescrollUni)
//注册全局顶部导航栏组件
import headNavbar from "@/components/head-navbar/";
Vue.component("head-navbar", headNavbar);

// 注册全局工具类
import appUtil from "./utils/util.js";
import tools from './common/tools.js'
import * as filters from './common/filters.js'
Vue.prototype.utils = appUtil;
Object.keys(filters).forEach(key => {
    Vue.filter(key, filters[key])
})
Vue.prototype.$tools=tools

// 注册全局跳转函数
Vue.prototype.toPage = function(id, name) {
	if (id == 0) {
		uni.navigateTo({
			url: name,
		})
	} else if (id == 1) {
		uni.reLaunch({
			url: name,
		})
	} else if (id == 2) {
		uni.navigateBack()
	}else if (id == 3) {
		uni.switchTab({
			url:name
		})
	}
};

// 注册全局变量
Vue.prototype.globalData={
	systemInfo:uni.getSystemInfoSync(),//设备信息
	color:{
		primary:"#3ECCA9",
		warning:"orangered",
		gray:"#787d83",
		border:"#eee",
		font:"#fff",
		backgroundGray:"#f6f7f9",
		shadow:"#505050",
		must:"#ff0000",
		ban:"#eee",
		beautiful:['#4fbed2','#EE7600','#fb665f','#88cb7e','#61b6f9','#f77896','#6F68DF']
	},
	keywordList:[]
}
Vue.prototype.$api = {prePage};
// 注册过滤函数
Vue.filter("invalidFilter", (str) => {
  return str=='null'||str=='undefined'?'':str;
})

const app = new Vue({
	store,
    ...App
})
app.$mount()